﻿#ifndef __DAHUA_GENICAM_CSYSTEM_H__
#define __DAHUA_GENICAM_CSYSTEM_H__

#include "Defs.h"
#include "Camera.h"
#include "StreamSource.h"
#include "ParameterNode.h"
#include "AcquisitionControl.h"
#include "AnalogControl.h"
#include "ImageFormatControl.h"
#include "ISPControl.h"
#include "UserSetControl.h"
#include "DeviceControl.h"
#include "TransportLayerControl.h"
#include "DigitalIOControl.h"

#include "EventSubscribe.h"

GENICAM_NAMESPACE_BEGIN

/// \~chinese
/// \brief 鍙戠幇璁惧銆佸垱寤哄父鐢ㄥ睘镐у璞?
/// \defgroup System 璁惧鍙戠幇銆佸睘镐у父鐢ㄥ璞″垱寤哄拰浜嬩欢璁㈤槄瀵硅薄鍒涘缓鎺ュ彛
/// \~english
/// \brief discover camera, and create common property instance
/// \defgroup System discover camera, create common property instance and create event subscribe instance interface
/// @{

/// \~chinese
/// \brief Class CSystem 鏋氢妇涓绘満镓€链夌墿鐞嗘帴鍙ｅ彲杈剧殑鍦ㄧ嚎鐩告満銆佸睘镐у父鐢ㄥ璞″垱寤恒€佷簨浠惰阒呭璞″垱寤哄强銮峰彇SDK鐗堟湰淇℃伅
/// \~english
/// \brief Class CSystem enumerate all cameras that the computer can reach, create common property object, create event subscription object, get SDK version information
class GENICAM_API CSystem
{
public:
	///< \~chinese
	///鏋氢妇锛氱墿鐞嗘帴鍙ｇ被鍨?
	///< \~english
	///enumeration: physical interface type
	enum EInterfaceType
	{
		typeGige = 0,	///< \~chinese GigE鍗忚        ///< \~english GigE Vision Protocol
		typeUsb3 = 1,	///< \~chinese USB3.0鍗忚      ///< \~english USB3.0 Vision Protocol
		typeCL   = 2,	///< \~chinese CAMERALINK鍗忚  ///< \~english Camera Link Protocol
        typePCIe = 3,	///< \~chinese PCIe鍗忚        ///< \~english PCIe Protocol
		typeAll  = 255  ///< \~chinese 蹇界暐鍗忚绫诲瀷锛岃澶囧彂鐜颁紶鍏ユ绫诲瀷镞讹紝琛ㄧず闇€鍙戠幇镓€链夋帴鍙ｄ笅镄勮澶?  ///< \~english ALL Supported Protocol
	};
	
	///< \~chinese
	///鏋氢妇锛氱墿鐞嗘帴鍙ｇ被鍨嬫墿灞曪紝鏀寔浠绘剰鎺ュ彛绫诲瀷镄勭粍鍚堬紝鍙敤浜庢柊镄勮澶囧彂鐜版帴鍙ｄ腑
	///< \~english
	///enumeration: physical interface type extension, support any combination of interface types, only can be used in new camera discovery interface
	enum EInterfaceTypeEx
	{
		interfaceTypeGige = 0x00000001,	   ///< \~chinese 缃戝崱鎺ュ彛绫诲瀷			///< \~english NIC type
		interfaceTypeUsb3 = 0x00000002,	   ///< \~chinese USB3.0鎺ュ彛绫诲瀷		///< \~english USB3.0 interface type
		interfaceTypeCL   = 0x00000004,	   ///< \~chinese CAMERALINK鎺ュ彛绫诲瀷	///< \~english CAMERALINK interface type
        interfaceTypePCIe = 0x00000008,    ///< \~chinese PCIe鎺ュ彛绫诲瀷          ///< \~english PCIe interface type
		interfaceTypeAll  = 0x00000000     ///< \~chinese 蹇界暐鎺ュ彛绫诲瀷锛岃澶囧彂鐜颁紶鍏ユ绫诲瀷镞讹紝琛ㄧず闇€鍙戠幇镓€链夋帴鍙ｄ笅镄勮澶?///< \~english ALL interfaces
	};
	
	/// \~chinese
    /// \brief CSystem鍗曚緥銮峰彇鎺ュ彛
    /// \return CSystem鍗曚緥瀵硅薄镄勬寚阍?
	/// \~english
	/// \brief CSystem singleton acquisition interface
	/// \return CSystem pointer to the singleton object
	static CSystem& getInstance();

	/// \~chinese
	/// \brief 鍙戠幇鎸囧畾鎺ュ彛绫诲瀷鍙揪镄勮澶?
	/// \param [out] vCameraPtrList 鎸囧畾鎺ュ彛绫诲瀷镓€链夊湪绾胯澶囧璞″垪琛?褰搃nterfaceType = typeAll 镞讹紝鍙戠幇镓€链夋帴鍙ｄ笅镄勫湪绾胯澶?
	/// \param [in]  interfaceType  鎺ュ彛绫诲瀷
	/// \return 鏄惁鎴愬姛
	/// \~english
	/// \brief discover reachable camera which has specified interface type
	/// \param [out] vCameraPtrList camera instance list of specified interface type. when interfaceType = typeAll, discover camerass in all interfaces
	/// \param [in]  interfaceType  interface type.
	/// \return success:true, fail:false
	bool discovery(Infra::TVector<ICameraPtr>& vCameraPtrList, EInterfaceType interfaceType = typeAll);
	
	/// \~chinese
	/// \brief 镙规嵁 Camera key "铡傚晢:搴忓垪鍙? 銮峰彇 Camera 鏅鸿兘鎸囬拡
	/// \param [in] pCameraKey 鐩告満镄刱ey
	/// \return Camera 鏅鸿兘鎸囬拡,鑻ヤ紶鍏ョ殑pCameraKey涓嶅瓨鍦ㄦ垨钥呴潪娉曪紝鍒栾繑锲炵┖鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief get smart pointers to Camera according to Camera key "vendor:serial number"
	/// \param [in] pCameraKey Camera's key
	/// \return Camera smart pointer. if the parameter pCameraKey does not exist or is invalid, return empty smart pointer object
	ICameraPtr getCameraPtr(const char * pCameraKey) const;
	
	/// \~chinese
	/// \brief 鍒涘缓娴佸璞?
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \param [in] channelId 娴侀€氶亾鍙凤紝榛樿涓?阃氶亾
	/// \return 娴佹櫤鑳芥寚阍埚璞?
	/// \~english
	/// \brief create stream object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \param [in] channelId stream channel id, default is 0 
	/// \return smart pointer to stream
	IStreamSourcePtr createStreamSource(const ICameraPtr &cameraPtr, uint16_t channelId = 0);

	/// \~chinese
	/// \brief 鍒涘缓浜嬩欢璁㈤槄瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return 浜嬩欢璁㈤槄瀵硅薄
	/// \~english
	/// \brief create event subscribe object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return event subscribe object
	IEventSubscribePtr createEventSubscribe(const ICameraPtr &cameraPtr);

	/// \~chinese
	/// \brief 鍒涘缓AcquisitionControl瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return AcquisitionControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create AcquisitionControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return AcquisitionControl object
	IAcquisitionControlPtr createAcquisitionControl(const ICameraPtr &cameraPtr);

	/// \~chinese
	/// \brief 鍒涘缓AnalogControl瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return AnalogControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create AnalogControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return AnalogControl object
	IAnalogControlPtr createAnalogControl(const ICameraPtr &cameraPtr);

	/// \~chinese
	/// \brief 鍒涘缓ISPControl瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return ISPControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create ISPControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return ISPControl object
	IISPControlPtr createISPControl(const ICameraPtr &cameraPtr);

	/// \~chinese
	/// \brief 鍒涘缓ImageFormatControl瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return ImageFormatControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create ImageFormatControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return ImageFormatControl object
	IImageFormatControlPtr createImageFormatControl(const ICameraPtr &cameraPtr);

	/// \~chinese
	/// \brief 鍒涘缓UserSetControl瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return UserSetControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create UserSetControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return UserSetControl object
	IUserSetControlPtr createUserSetControl(const ICameraPtr &cameraPtr);

	/// \~chinese
	/// \brief 鍒涘缓DeviceControl瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return DeviceControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create DeviceControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return DeviceControl object
	IDeviceControlPtr createDeviceControl(const ICameraPtr &cameraPtr);
	 
	/// \~chinese
	/// \brief 鍒涘缓TransportLayerControl瀵硅薄
	/// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
	/// \return TransportLayerControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create TransportLayerControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return TransportLayerControl object
	ITransportLayerControlPtr createTransportLayerControl(const ICameraPtr &cameraPtr);

    /// \~chinese
    /// \brief 鍒涘缓DigitalIOControl瀵硅薄
    /// \param [in] cameraPtr 鐩告満鏅鸿兘鎸囬拡瀵硅薄
    /// \return DigitalIOControl鏅鸿兘鎸囬拡瀵硅薄
	/// \~english
	/// \brief create DigitalIOControl object
	/// \param [in] cameraPtr smart pointer to Camera
	/// \return DigitalIOControl object
    IDigitalIOControlPtr createDigitalIOControl(const ICameraPtr &cameraPtr);

	/// \~chinese
	/// \brief 銮峰彇鐗堟湰淇℃伅
	/// \return 鐗堟湰淇℃伅
	/// \~english
	/// \brief get version information
	/// \return version information
	const char* getVersion() const;

private:
	/// \~chinese
	/// \brief 鏋勯€犲嚱鏁?
	/// \~english
	/// \brief constructor function
	CSystem();
	
	/// \~chinese
	/// \brief 鎷疯礉鏋勯€犲嚱鏁?
	/// \~english
	/// \brief copy constructor function
	CSystem(const CSystem&); 
	
	/// \~chinese
	/// \brief 璧嫔€煎嚱鏁?
	/// \~english
	/// \brief assignment function
	CSystem& operator = (const CSystem&);

	/// \~chinese
	/// \brief 鏋愭瀯鍑芥暟
	/// \~english
	/// \brief destructor function
	~CSystem();
	
	class Impl;
	Impl *m_pImpl;
};

/// @}

GENICAM_NAMESPACE_END

#endif//__DAHUA_GENICAM_CSYSTEM_H__
